package org.example;

import bean.MyClass;
import bean.Student;
import bean.Teacher;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.ArrayList;
import java.util.List;

public class Main2 {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context =
        new ClassPathXmlApplicationContext("springA.xml");
        List<Student> s = new ArrayList<Student>();
        Student s1 = (Student) context.getBean("stu");
        s1.setName("成龙");s1.setAge(18);
        s.add(s1);
        Student s2 = (Student) context.getBean("stu");
        s2.setName("周杰伦");s2.setAge(19);
        s.add(s2);
        Student s3 = (Student) context.getBean("stu");
        s3.setName("周润发");s3.setAge(17);
        s.add(s3);
        Student s4 = (Student) context.getBean("stu");
        s.add(s4);
        MyClass myClass = (MyClass) context.getBean("myclass");
        myClass.setName("210451班");
        myClass.setStudents(s);

        Teacher teacher = (Teacher) context.getBean("teacher");
        teacher.setName("老王");teacher.setMyClass(myClass);
        for (Student e:s) {
            System.out.println(e);
        }
        System.out.println(myClass);
        System.out.println(teacher);
    }
}
